import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from 'typeorm';
import { IsNotEmpty, IsString, Length } from 'class-validator';

@Entity()
export class User extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 20,
  })
  @IsNotEmpty()
  @Length(6, 20, {
    message: '账号长度必须在6-20之间',
  })
  @IsString({ message: '账号必须是字符串' })
  account: string;

  @Column({
    length: 20,
  })
  @Length(6, 20, {
    message: '密码长度必须在6-20之间',
  })
  @IsString({ message: '密码必须是字符串' })
  password: string;
}
